home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
...taking it to the Macs!
/
...taking it to the Macs!.iso
/
Extras
/
ActiveX Mac SDK
/
ActiveX SDK
/
Control Common
/
CEnumConnectionPoints.cpp
< prev
next >
Wrap
Text File
|
1996-10-17
|
3KB
|
166 lines
//
#include "ocheaders.h"
#include <LArray.h>
#include "CEnumConnectionPoints.h"
//
// CEnumConnectionPoints::CEnumConnectionPoints
//
CEnumConnectionPoints::CEnumConnectionPoints(LArray* ConnectionPoints)
{
unsigned long i;
IConnectionPoint* cp;
m_RefCount = 0;
m_Current = 1;
// Create the enumerator's connection points array
m_ConnectionPoints = new LArray(sizeof(IConnectionPoint*));
// Copy all the connection point pointers into our local array
for ( i = 1; i <= ConnectionPoints->GetCount(); i ++ )
{
ConnectionPoints->FetchItemAt(i, &cp);
m_ConnectionPoints->InsertItemsAt(1, i, &cp);
cp->AddRef();
}
}
//
// CEnumConnectionPoints::~CEnumConnectionPoints
//
CEnumConnectionPoints::~CEnumConnectionPoints(void)
{
unsigned long i;
IConnectionPoint* cp;
// Release all the connection points we have
for ( i = 1; i <= m_ConnectionPoints->GetCount(); i ++ )
{
m_ConnectionPoints->FetchItemAt(i, &cp);
cp->Release();
}
delete m_ConnectionPoints;
}
//
// CEnumConnectionPoints::IUnknown::QueryInterface
//
// Returns a pointer to the specified interface on a component to which a
// client currently holds an interface pointer.
//
STDMETHODIMP
CEnumConnectionPoints::QueryInterface(REFIID RefID, void** Obj)
{
void* pv;
if (RefID == IID_IUnknown)
pv = (void*) this;
else if (RefID == IID_IEnumConnectionPoints )
pv = (void*)(IEnumConnectionPoints*) this;
else {
*Obj = NULL;
return ResultFromScode(E_NOINTERFACE);
}
*Obj = pv;
((IUnknown*) pv)->AddRef();
return ResultFromScode(S_OK);
}
//
// CEnumConnectionPoints::IUnknown::AddRef
//
// Increments the reference count for the calling interface.
//
STDMETHODIMP_(ULONG)
CEnumConnectionPoints::AddRef(void)
{
return ++m_RefCount;
}
//
// CEnumConnectionPoints::IUnknown::Release
//
// Decrements the reference count for the calling interface on a object. If
// the reference count on the object falls to zero, the object is freed.
//
STDMETHODIMP_(ULONG)
CEnumConnectionPoints::Release(void)
{
if (--m_RefCount != 0)
return m_RefCount;
delete this;
return 0;
}
//
// CEnumConnectionPoints::IEnumConnectionPoints::Next
//
STDMETHODIMP
CEnumConnectionPoints::Next(unsigned long NumRequested,
IConnectionPoint** ConnectionPoint,
unsigned long* NumReturned)
{
unsigned long Returned = 0;
unsigned long RemainingRequests = NumRequested;
while ( m_Current <= m_ConnectionPoints->GetCount() && RemainingRequests > 0 )
{
m_ConnectionPoints->FetchItemAt(m_Current, ConnectionPoint);
(*ConnectionPoint)->AddRef();
// Move to next connection point
ConnectionPoint++;
// One more returned, one less requested
Returned ++;
RemainingRequests --;
// Next item please
m_Current++;
}
// if the client is interested, pass this info back
if ( NumReturned )
(*NumReturned) = Returned;
// Set the correct return value
if ( Returned == NumRequested )
return ResultFromScode(S_OK);
else
return ResultFromScode(S_FALSE);
}
//
// CEnumConnectionPoints::IEnumConnectionPoints::Skip
//
STDMETHODIMP
CEnumConnectionPoints::Skip(unsigned long cConnections)
{
#pragma unused (cConnections)
return E_NOTIMPL;
}
//
// CEnumConnectionPoints::IEnumConnectionPoints::Clone
//
STDMETHODIMP
CEnumConnectionPoints::Clone(IEnumConnectionPoints** Enum)
{
#pragma unused (Enum)
return E_NOTIMPL;
}